<template>
	<view class="container">
		<!-- 故障信息部分 -->
		<view class="form-section">
			<view class="form-group">
				<view class="section-title">故障信息</view>
				<up-form labelPosition="left" :model="faultForm" :rules="faultRules" labelWidth="auto"
					ref="faultFormRef">
					<u-form-item label="故障单号" prop="ldbh" required>
						<up-input v-model="faultForm.ldbh" placeholder="请右侧选择" readonly :disabled="isDisabled">
							<template #suffix>
								<u-icon name="arrow-right" size="28" @click="showgzdh = true" v-if="!isDisabled" />
							</template>
						</up-input>
						<popUp :show="showgzdh" :dataList="gzdhDataList" :lineList="gzdhLine" @scrolltolower="gzdhLower"
							@close="showgzdh = false" @click="gzdhClick" @search="gzdhSearch">
						</popUp>
					</u-form-item>

					<u-form-item label="操作人员">
						<up-input v-model="faultForm.czry" border="bottom" :disabled="isDisabled" readonly>
							<template #suffix>
								<u-icon name="arrow-right" size="28" @click="showczry = true" v-if="false" />
							</template>
							<popUp :show="showczry" :dataList="czryList" :lineList="czryLine" @scrolltolower="czryLower"
								@close="showczry = false" @click="czryClick" @search="czrySearch">
							</popUp>
						</up-input>
					</u-form-item>

					<u-form-item label="设备编号">
						<up-input v-model="faultForm.sbbh" border="bottom" placeholder="请输入设备编号" :disabled="isDisabled"
							@blur="handlesbbhBlur" readonly>
							<template #suffix>
								<u-icon name="scan" size="28" @click="scanCode('sbbh')" v-if="false" />
							</template>
						</up-input>
					</u-form-item>

					<u-form-item label="设备名称">
						<up-input v-model="faultForm.sbmc" border="bottom" placeholder="自动带出" readonly />
					</u-form-item>

					<u-form-item label="故障时间">
						<u-datetime-picker v-model="faultDateTime" mode="datetime" :show="showFaultDate"
							@confirm="faultDateConfirm" @cancel="showFaultDate = false" />
						<u-button class="datetime-btn" @click="openFaultDateTimePicker" disabled :hair-line="false"
							:plain="true">
							{{ faultForm.faultdate&&faultForm.gzsj ? `${faultForm.faultdate} ${faultForm.gzsj || ''}` : '请选择日期时间' }}
						</u-button>
					</u-form-item>

					<u-form-item label="故障分类">
						<u-picker :show="showgzfl" :columns="gzflColumns" @cancel="showgzfl = false"
							@confirm="gzflConfirm" keyName="label">
						</u-picker>
						<u-button @click="showgzfl = true" disabled>{{ faultForm.gzfl || '右侧选择' }}</u-button>
					</u-form-item>

					<u-form-item label="故障部位">
						<up-input v-model="faultForm.faultpart" placeholder="请输入/右侧选择" readonly :disabled="isDisabled">
							<template #suffix>
								<u-icon name="arrow-right" size="28" @click="showgzbw = true" v-if="false" />
							</template>
						</up-input>
						<popUp :show="showgzbw" :dataList="gzBwDataList" :lineList="gzBwLine" @scrolltolower="gzbwLower"
							@close="showgzbw = false" @click="gzbwClick" @search="gzSearch">
						</popUp>
					</u-form-item>

					<u-form-item label="故障原因">
						<u-picker :show="showgzyy" @cancel="showgzyy = false" :columns="gzyyColumns"
							@confirm="gzyyConfirm" keyName="label"></u-picker>
						<u-button @click="showgzyy = true" :disabled="true">{{ faultForm.gzyy || '请右侧选择' }}</u-button>
					</u-form-item>

					<u-form-item class="gznr-textarea">
						<view class="textarea-title">
							<text class="textarea-title-text">故障记录</text>
							<u-icon name="arrow-right" size="28" @click="showgzjl = true" v-if="false"
								class="title-icon" />
						</view>
						<view class="textarea-container">
							<up-textarea class="textarea-style" v-model="faultForm.gznr" placeholder="请输入/右侧选择故障记录"
								maxlength="500" autoHeight disabled count />
						</view>
						<popUp :show="showgzjl" :dataList="gzjlList" :lineList="gzjlLine" @scrolltolower="gzjlLower"
							@open="gzjlOpen" @close="showgzjl = false" @click="gzjlClick" @search="gzjlSearch"></popUp>
					</u-form-item>

					<view class="toggle-button" v-show="isExpanded">
						<u-form-item label="维修班组">
							<up-input v-model="faultForm.wxbz" border="bottom" placeholder="自动带入/输入"
								:disabled="isDisabled" readonly />
						</u-form-item>

						<u-form-item label="维修人员">
							<up-input v-model="faultForm.wxry" border="bottom" placeholder="自动带入/输入"
								:disabled="isDisabled" readonly />
						</u-form-item>

						<u-form-item label="维修时间">
							<u-datetime-picker v-model="MaintDateTime" mode="datetime" :show="showMaintDate"
								@confirm="MaintDateConfirm" @cancel="showMaintDate = false" />
							<u-button class="datetime-btn" @click="openMaintDateTimePicker" disabled :hair-line="false"
								:plain="true">
								{{ faultForm.maintdate&&faultForm.xfsj ? `${faultForm.maintdate} ${faultForm.xfsj || ''}` : '请选择日期时间' }}
							</u-button>
						</u-form-item>

						<u-form-item label="计划停机">
							<up-switch v-model="faultForm.jhtj" @change="jhtjChange" :disabled="true" />
						</u-form-item>

						<u-form-item label="停机台时（小时）" v-if="faultForm.jhtj==1">
							<up-number-box v-model="faultForm.tjts" :min="1" :max="100" :step="1" decimal-length="2"
								:disabled="true" />
						</u-form-item>

						<u-form-item label="录入人员">
							<up-input v-model="faultForm.lrry" border="bottom" disabled placeholder="请输入" />
						</u-form-item>

						<u-form-item label="录入日期">
							<up-input v-model="faultForm.lrrq" border="bottom" disabled placeholder="请输入" />
						</u-form-item>

					</view>

					<view class="toggle-button" @click="toggleMore">
						<text>{{ isExpanded ? '收起 ▴' : '展开更多 ▾' }}</text>
					</view>

				</up-form>

			</view>

			<view>
				<u-divider :dot="true" />
			</view>

			<view class="form-group">
				<view class="section-title">维修填报</view>
				<up-form labelPosition="left" :model="repairForm" :rules="repairRules" labelWidth="auto"
					ref="repairFormRef">

					<u-form-item label="维修单号:" required>
						<up-input v-model="repairForm.ldbh" placeholder="自动生成" readonly :disabled="isDisabled" />
					</u-form-item>

					<u-form-item label="维修人员" prop="wxry" required>
						<up-input v-model="repairForm.wxry" border="bottom" placeholder="请输入/右侧选择"
							:disabled="isDisabled">
							<template #suffix>
								<u-icon name="arrow-right" size="28" @click="showwzry = true" v-if="!isDisabled" />
							</template>
						</up-input>
						<u-picker :show="showwzry" :columns="wxryColumns" @change="wxryChange" @confirm="wxryConfirm"
							@cancel="showwzry = false" keyName="label"></u-picker>
					</u-form-item>

					<u-form-item label="故障现象" prop="gznr" required>
						<textarea class="textarea-field" v-model="repairForm.gznr" placeholder="请输入故障现象..."
							:disabled="isDisabled" />
					</u-form-item>

					<u-form-item label="处理过程" prop="wxnr" required>
						<textarea class="textarea-field" v-model="repairForm.wxnr" placeholder="请输入处理过程..."
							:disabled="isDisabled" />
					</u-form-item>

					<u-form-item label="耗材:">
						<up-input v-model="repairForm.ghlj" placeholder="请输入耗材信息" :disabled="isDisabled" />
					</u-form-item>

					<u-form-item label="维修日期:">
						<u-button class="datetime-btn" @click="openRepairDatePicker" :hair-line="false" :plain="true"
							:disabled="isDisabled">
							{{ repairForm.rq ? `${repairForm.rq}` : '请选择维修日期' }}
						</u-button>
						<u-datetime-picker ref="datetimePickerRef" v-model="repairDate" mode="date" :show="showrq"
							@confirm="RepairRqConfirm" @cancel="showrq = false" />
					</u-form-item>


					<u-form-item label="维修结果:" prop="result" required>
						<up-input v-model="repairForm.result" placeholder="请输入维修结果" :disabled="isDisabled" />
					</u-form-item>

					<u-form-item label="是否停台">
						<up-switch v-model="repairForm.whetherstop" @change="whetherstopChange"
							:disabled="isDisabled" />
					</u-form-item>

					<u-form-item label="停机台时:">
						<up-number-box v-model="repairForm.tjts" :min="0" :max="100" :step="1" decimal-length="2"
							:disabled="!repairForm.whetherstop&&!isDisabled" />
					</u-form-item>

					<u-form-item label="维修性质:">
						<up-input v-model="repairForm.type" placeholder="请输入维修性质" readonly>
							<template #suffix>
								<u-icon name="arrow-right" size="28" @click="showwxxz = true" v-if="!isDisabled" />
							</template>
						</up-input>
						<u-picker :show="showwxxz" :columns="wxxzColumns" @cancel="showwxxz = false"
							@confirm="wxxzConfirm" keyName="label">
						</u-picker>
					</u-form-item>

					<u-form-item label="备注:">
						<textarea class="textarea-field" v-model="repairForm.bz" placeholder="请输入备注信息..."
							:disabled="isDisabled" />
					</u-form-item>


					<view class="btn-container" v-show="mode==='add'" :disabled="isDisabled">
						<button class="submit-btn" @tap="submitRepairCheck">提交维修记录</button>
					</view>

					<!-- 暂定为只有待确认状态才可以进行修改 -->
					<view class="btn-container" v-show="mode==='details'&&deviceState == 1 " :disabled="isDisabled">
						<button class="submit-btn" @tap="submitRepairCheck">提交修改</button>
					</view>

				</up-form>
			</view>



		</view>

		<view class="action-buttons">
			<u-button class="action-btn confirm-btn" type="primary" size="medium" @click="onConfirm"
				v-show="deviceState === 1&& mode==='details'&&this.$userPerssion.sbyPermission(whichworhshop)">
				<u-icon name="checkmark-circle" size="18" color="#fff"></u-icon>
				<text>设备员确认</text>
			</u-button>

			<u-button class="action-btn cancel-confirm-btn" type="warning" size="medium" @click="cancelConfirm"
				v-show="deviceState === 2&& mode==='details'&&this.$userPerssion.sbyPermission(whichworhshop)">
				<u-icon name="close-circle" size="18" color="#fff"></u-icon>
				<text>撤销确认</text>
			</u-button>

			<u-button class="action-btn examine-btn" type="success" size="medium" @click="onExamine"
				v-show="deviceState === 2&& mode==='details'&&this.$userPerssion.sbkPermission(whichworhshop)">
				<u-icon name="edit-pen" size="18" color="#fff"></u-icon>
				<text>设备科审核</text>
			</u-button>

			<u-button class="action-btn cancel-examine-btn" type="error" size="medium" @click="cancelExamine"
				v-show="deviceState === 3&& mode==='details'&&this.$userPerssion.sbkPermission(whichworhshop)">
				<u-icon name="close-circle" size="18" color="#fff"></u-icon>
				<text>撤销审核</text>
			</u-button>
		</view>
		<view style="margin-bottom: 20px;"></view>

		<view>
			<Modal :isVisible="isModalVisible" :message="'确定要提交吗？'" @cancel="handleCancel" @confirm="onSubmit" />
		</view>

	</view>
</template>

<script>
	import Modal from '@/components/bottons/prompt.vue'; // 请检查路径是否正确
	import popUp from "../../../components/popUp/popUp.vue";
	import {
		isBankObj,
		deepClone
	} from '../../../common/commonUnits';
	export default {
		components: {
			Modal,
			popUp
		},
		data() {
			return {
				isEditMode: true, // 编辑状态控制
				isModalVisible: false, // 控制提示框显示
				showgzdh: false,
				showgzcd: false,
				showFaultDate: false,
				showFaultTime: false,
				showxfsj: false,
				showgzfl: false,
				showgzbw: false,
				showgzyy: false,
				showwzry: false,
				showgzjl: false,
				showMaintDate: false,
				showczry: false,
				showrq: false,
				showwxxz: false,

				//表单校验
				faultRules: {
					"ldbh": {
						type: 'string',
						required: true,
						message: '请选择故障单号',
						trigger: ['blur', 'change']
					},
				},

				repairRules: {

					wxry: {
						type: 'string',
						message: '请选择维修人员',
						required: true,
						trigger: ['blur', 'change']
					},
					gznr: {
						type: 'string',
						message: '请输入故障现象',
						required: true,
						trigger: ['blur', 'change']
					},
					wxnr: {
						type: 'string',
						message: '请输入处理过程',
						required: true,
						trigger: ['blur', 'change']
					},
					result: {
						type: 'string',
						message: '请输入维修结果',
						required: true,
						trigger: ['blur', 'change']
					},

				},

				faultForm: {
					createtime: this.$commonUnits.FormatTimeOne(new Date(), true, true),
					createuserid: this.$commonUnits.getUserId(),
					czry: '',
					faultdate: this.$commonUnits.FormatTimeOne(new Date(), false, false),
					faultlevel: '',
					faultpart: '',
					faulttime: '',
					faulttype: '',
					gzcd: '',
					gzfl: '',
					gznr: '',
					gzsj: '',
					gzyy: '',
					id: '',
					jhtj: false,
					ldbh: '',
					lrrq: this.$commonUnits.FormatTimeOne(new Date(), true, true),
					lrry: this.$commonUnits.getUserId(),
					maintdate: '',
					productionprocess: '',
					rq: '',
					sbbh: '',
					sbid: '',
					sbmc: '',
					sbyqr: '',
					sbyqrtime: '',
					sbysh: '',
					sbyshtime: '',
					tjts: '',
					updatetime: '',
					updateuserid: '',
					wxbz: '',
					wxnr: '',
					wxry: '',
					xfsj: '',
					year: new Date().getFullYear(),
				},

				isExpanded: false, // 控制是否展开
				repairForm: {
					id: '',
					ldbh: '', //维修单号
					rq: this.$commonUnits.FormatTimeOne(new Date(), false, false),
					sbid: '',
					gznr: '',
					tjts: '', //停台台时
					wxnr: '',
					ghlj: '',
					wxry: '', //维修人员
					bz: '',
					year: '',
					result: '',
					whetherstop: '', //是否停台
					type: '',
					name: '',
					gzdh: '',
					updateuserid: '',
					sbysh: '',
					sbyshtime: '',
					sbyqr: '',
					sbyqrtime: '',
					createtime: this.$commonUnits.FormatTimeOne(new Date(), true, true),
					createuserid: this.$commonUnits.getUserId(),
				},
				deviceId: '', //设备id
				faultDateTime: '', //拼接后的故障日期+故障时间
				MaintDateTime: '', //拼接后的修复日期+时间
				repairDate: '',

				// 故障分类相关
				gzfl: '', // 显示用的故障分类名称
				gzflColumns: [
					[]
				], // picker使用的数据结构

				// 故障原因相关
				gzyy: '', // 显示用的故障原因名称
				gzyyColumns: [
					[]
				], // picker使用的数据结构

				// 故障程度相关
				gzcd: '', // 显示用的故障程度名称
				gzcdColumns: [
					[]
				], // picker使用的数据结构

				// 维修性质相关
				wxxz: '', // 维修性质名称
				wxxzColumns: [
					[{
							label: '维修',
							value: '维修'
						},
						{
							label: '加班维修',
							value: '加班维修'
						}
					]
				],

				// 故障单号
				gzdhLine: [{
						name: '故障单号',
						label: 'ldbh',
					},
					{
						name: '录入人员',
						label: 'lrry',
					},
					{
						name: '设备编号',
						label: 'sbbh',
					}
				],
				gzdhDataList: [],

				// 故障部位
				gzBwLine: [{
					name: '部位名称',
					label: 'equipmentstructure'
				}],
				gzBwDataList: [],


				// 维修人员
				wxryLine: [{
						name: '人员名称',
						label: 'bzry'
					},
					{
						name: '所在班组',
						label: 'bzmc'
					},
				],
				wxryList: [],

				wxryColumns: [
					[],
					[]
				], // 两列数据
				wxryMap: {}, // 班组-人员映射
				currentWxryTeam: '', // 当前选中班组


				// 操作人员
				czryLine: [{
						name: '人员编号',
						label: 'empcode'
					},
					{
						name: '人员名称',
						label: 'empname'
					},
				],
				czryList: [],

				// 故障记录
				gzjlLine: [{
						name: '故障编号',
						label: 'code'
					},
					{
						name: '故障内容',
						label: 'name'
					},
				],
				gzjlList: [],

				gzdhsearchData: {
					gzdh: '',
				},
				gzdhpagination: {
					pageNum: 1, // 当前页码
					pageSize: 20, // 每页条数
					total: 0, // 总条数
				},

				gzbwsearchData: {
					equipmentstructure: '',
				},
				gzbwpagination: {
					pageNum: 1, // 当前页码
					pageSize: 20, // 每页条数
					total: 0, // 总条数
				},

				czrysearchData: {
					employeeName: '',
				},
				czrypagination: {
					pageNum: 1, // 当前页码
					pageSize: 20, // 每页条数
					total: 0, // 总条数
				},
				whichworhshop: "",
			};
		},
		mounted() {
			this.repairForm.gznr = this.getDefaultValue(); // 调用方法获取默认值
		},
		computed: {
			deviceState() {
				const {
					sbyqr,
					sbyqrtime,
					sbysh,
					sbyshtime
				} = this.repairForm;

				// 状态1: sbyqr和sbyqrtime都为空
				if ((!sbyqr || sbyqr === '') && (!sbyqrtime || sbyqrtime === '')) {
					return 1;
				}
				// 状态2: sbyqr和sbyqrtime不为空，sbhsh和sbyshtime为空
				else if (sbyqr && sbyqr !== '' && sbyqrtime && sbyqrtime !== '' &&
					(!sbysh || sbysh === '') && (!sbyshtime || sbyshtime === '')) {
					return 2;
				}
				// 状态3: 所有字段都不为空
				else if (sbyqr && sbyqr !== '' && sbyqrtime && sbyqrtime !== '' &&
					sbysh && sbysh !== '' && sbyshtime && sbyshtime !== '') {
					return 3;
				}
				return 0;
			},
			isDisabled() {
				return this.deviceState != 1 && this.mode === 'details';
			},

		},

		onReady() {
			this.$refs.faultFormRef.setRules(this.faultRules)
			this.$refs.repairFormRef.setRules(this.repairRules)
			this.$refs.datetimePickerRef.setFormatter(this.formatter)
		},

		onLoad(e) {
			const {
				mode,
				id,
				ldbh,
				whichworhshop
			} = e;
			this.mode = e.mode
			this.whichworhshop = e.whichworhshop
			if (mode === 'add') { //新增状态
				const timestamp = Date.now(); // 当前时间戳
				var userInfo = this.$commonUnits.getUserInfo();
				let {
					BZ,
					BM
				} = this.$userPerssion.getUserPermission();

				// this.faultForm.lrrq = this.formatTimestamp(timestamp)
				// this.faultForm.lrry = userInfo.userName
				// this.faultForm.czry = userInfo.userName //设置操作人员为当前用户
				// this.faultForm.createuserid = this.$commonUnits.getUserId();
				// this.faultForm.createtime = this.$commonUnits.FormatTimeOne(new Date(), true, true);
				// this.faultForm.wxbz = BZ
				// this.faultForm.wxry = userInfo.userName

				this.repairForm.wxry = userInfo.userName
				this.repairForm.lrry = userInfo.userName;
				this.repairForm.czry = userInfo.userName;
				this.repairForm.lrrq = this.$commonUnits.FormatTimeOne(timestamp, true, true);
				this.repairForm.createuserid = this.$commonUnits.getUserId();
				this.repairForm.createtime = this.$commonUnits.FormatTimeOne(new Date(), true, true);
			} else { //修改状态
				if (id) {
					this.repairForm.id = id;
					this.getRepairData(id); //获取维修信息
				}
				if (e.ldbh) {
					this.getFaultData(e.ldbh) //获取故障消息
				}
			}

			// 并行加载所有类型数据
			Promise.all([
				this.getFaultTypeList('GZFL'), //故障分类
				this.getFaultTypeList('GZYY'), //故障原因
				this.getFaultTypeList('GZCD'), //故障程度
				this.getEmployeeList(), //获取操作人员
			]).then(() => {
				this.getWxRyDataList(); //维修人员
				this.getGzdhDataList(); //故障单号
			}).catch(err => {
				uni.$u.toast('初始化数据加载失败,请重试');
			});
		},

		methods: {
			whetherstopChange(e) {
				if (e === false) {
					this.repairForm.tjts = 0
				}
			},

			toggleMore() {
				this.isExpanded = !this.isExpanded;
			},
			getDefaultValue() {
				// 模拟动态生成默认值
				return this.faultForm.gznr;
			},
			handleCancel() {
				this.isModalVisible = false; // 关闭弹窗
			},
			handleConfirm() {
				if (!this.isConfirmDisabled) {
					this.$emit("confirm");
				}
			},

			gzflConfirm(e) { // 故障分类确认
				this.handlePickerConfirm(e, 'gzfl', 'gzfl');
			},
			gzyyConfirm(e) { // 故障原因确认
				this.handlePickerConfirm(e, 'gzyy', 'gzyy');
			},
			gzcdConfirm(e) { // 故障程度确认
				this.handlePickerConfirm(e, 'gzcd', 'gzcd');
			},
			handlePickerConfirm(e, displayKey, dataKey) {
				const {
					value
				} = e;
				if (!value || value.length === 0 || value[0].length === 0) { //没有数据
					this[`show${dataKey}`] = false;
					return;
				}
				const selected = value[0];
				// 更新显示值
				this[displayKey] = selected.label;
				this.faultForm[dataKey] = selected.value;
				this[`show${dataKey}`] = false;
			},
			wxxzConfirm(e) {
				const {
					value
				} = e;
				const selected = value[0];
				this.wxxz = selected.label;
				this.repairForm.type = selected.value
				this.showwxxz = false
			},

			async getGzdhDataList() {
				try {
					const currentParams = {
						// status: 1,
						ldbh: this.gzdhsearchData.ldbh,
					}
					// 如果搜索条件变化，重置分页
					if (JSON.stringify(currentParams) !== JSON.stringify(this.searchParams)) {
						this.gzdhpagination.pageNum = 1;
						this.gzdhDataList = [];
					}
					this.searchParams = {
						...currentParams
					};
					const params = {
						...currentParams,
						pageNum: this.gzdhpagination.pageNum,
						pageSize: this.gzdhpagination.pageSize
					};
					const res = await this.$commonUnits.postRequest(
						"deviceFaultRecord.deviceFaultRecord.getFaultRecordList.mobile",
						params
					);
					if (!res.result || res.result.length === 0) {
						uni.$u.toast(`暂时没有可以选择的故障单号，请重试`);
					}
					// 处理数据
					const newData = res.result.list;
					if (this.gzdhpagination.pageNum === 1) {
						this.gzdhDataList = newData;
					} else {
						this.gzdhDataList = [...this.gzdhDataList, ...newData];
					}
				} catch (err) {
					uni.$u.toast(`获取人员数据不存在，请重试`);
					// 初始化空数据
					this.gzdhDataList = []
				}
			},

			//初始化加载故障分类GZFL，原因GZYY，程度GZCD
			async getFaultTypeList(type) {
				try {
					const res = await this.$commonUnits.postRequest(
						"deviceFaultRecord.deviceFaultRecord.getFaultType.mobile", {
							type: type
						}
					);
					if (!res.result || res.result.length === 0) {
						uni.$u.toast(`获取${this.getTypeName(type)}数据不存在，请重试`);
					}
					// 根据不同类型处理数据
					switch (type) {
						case 'GZFL': // 故障分类
							this.gzflColumns = [res.result.map(item => ({
								label: item.gzfl || '',
								value: item.gzfl
							}))];
							break;

						case 'GZYY': // 故障原因
							this.gzyyColumns = [res.result.map(item => ({
								label: item.yyfl || '',
								value: item.yyfl
							}))];
							break;

						case 'GZCD': // 故障程度
							this.gzcdColumns = [res.result.map(item => ({
								label: item.cdfl || '',
								value: item.cdfl
							}))];
							break;
					}

				} catch (err) {
					uni.$u.toast(`获取${this.getTypeName(type)}失败，请重试`);
					// 初始化空数据
					switch (type) {
						case 'GZFL':
							this.gzflColumns = [
								[]
							];
							break;
						case 'GZYY':
							this.gzyyColumns = [
								[]
							];
							break;
						case 'GZCD':
							this.gzcdColumns = [
								[]
							];
							break;
					}
				}
			},

			async getEmployeeList(type) {
				try {
					const currentParams = {
						employeeName: this.czrysearchData.employeeName,
					}
					// 如果搜索条件变化，重置分页
					if (JSON.stringify(currentParams) !== JSON.stringify(this.searchParams)) {
						this.czrypagination.pageNum = 1;
						this.czryList = [];
					}
					this.searchParams = {
						...currentParams
					};
					const params = {
						...currentParams,
						pageNum: this.czrypagination.pageNum,
						pageSize: this.czrypagination.pageSize
					};
					const res = await this.$commonUnits.postRequest(
						"deviceFaultRecord.deviceFaultRecord.getEmployeeList.mobile",
						params
					);
					if (!res.result || res.result.length === 0) {
						uni.$u.toast(`获取人员数据不存在，请重试`);
					}
					// 处理数据
					const newData = res.result.list;
					if (this.czrypagination.pageNum === 1) {
						this.czryList = newData;
					} else {
						this.czryList = [...this.czryList, ...newData];
					}
				} catch (err) {
					uni.$u.toast(`获取人员数据不存在，请重试`);
					// 初始化空数据
					this.czryList = []
				}
			},

			handlesbbhBlur(val) { //设备变化，获取该设备下的故障部位
				this.getsbData(val);
				this.getGzBwDataList();
			},

			// 辅助方法:获取类型名称
			getTypeName(type) {
				const map = {
					'GZFL': '故障分类',
					'GZYY': '故障原因',
					'GZCD': '故障程度'
				};
				return map[type] || '数据';
			},

			getsbData(id) { //获取设备信息
				this.$commonUnits.postRequest(
					"deviceFaultRecord.deviceFaultRecord.getZcglSbtzByCode.mobile", {
						code: id
					}
				).then(res => {
					if (!res.result || res.result.length === 0) {
						uni.showToast({
							title: '输入的设备编号不存在，请重试!',
							icon: 'none'
						});
					} else {
						this.faultForm.sbid = res.result[0]["id"]
						this.faultForm.sbmc = res.result[0]["sbmc"]
						// this.faultForm.bz = res.result[0]["gdbz"]  //班组为设备所在班组
						this.repairForm.sbid = res.result[0]["id"]
					}
				}).catch(err => {
					uni.showToast({
						title: '获取设备数据不存在，请重试!',
						icon: 'fail'
					});
				});
			},

			getGzBwDataList() { // 获取设备故障部位（前提:选择设备编号）
				if (this.faultForm.sbbh != null) {
					const sblx = this.faultForm.sbbh.slice(0, 12)
					this.$commonUnits.postRequest(
						"deviceFaultRecord.deviceFaultRecord.getFaultPart.mobile", {
							equipmentcode: sblx,
							equipmentstructure: this.gzbwsearchData.equipmentstructure
						}
					).then(res => {
						if (!res.result || res.result.length === 0) {
							this.gzBwDataList = [];
							uni.showToast({
								title: '该设备类型下暂无故障部位数据',
								icon: 'none'
							});
						} else {
							this.gzBwDataList = res.result
						}
					}).catch(err => {
						this.gzBwDataList = [];
					});
				} else {
					uni.showToast({
						title: '请先选择设备！',
						icon: 'exception'
					});
				}
			},

			//获取维修人员数据
			async getWxRyDataList() {
				try {
					const res = await this.$commonUnits.postRequest(
						"deviceFaultRecord.deviceFaultRecord.getFaultTeam.mobile"
					);
					if (!res.result || res.result.length === 0) {
						this.wxryList = [];
						uni.showToast({
							title: '暂无数据',
							icon: 'fail'
						});
						return;
					}
					// 重组数据结构
					const teamMap = {};
					res.result.forEach(item => {
						if (!teamMap[item.bzmc]) {
							teamMap[item.bzmc] = [];
						}
						teamMap[item.bzmc].push({
							label: item.bzry,
							value: item.bzry
						});
					});
					this.wxryMap = teamMap;
					this.wxryColumns = [
						Object.keys(teamMap).map(team => ({
							label: team,
							value: team
						})), // 班组列
						teamMap[Object.keys(teamMap)[0]] || [] // 默认第一个班组的人员
					];
				} catch (err) {
					console.error(err);
					this.wxryList = [];
				}
			},

			//获取故障记录数据
			async getFaultData(ldbh) {
				try {
					const res = await this.$commonUnits.postRequest(
						"deviceFaultRecord.deviceFaultRecord.getFaultDetail.mobile", {
							id: '',
							ldbh: ldbh,
						}
					);
					if (!res.result) {
						this.faultForm = {};
						uni.showToast({
							title: '获取维修单数据异常，请重试!',
							icon: 'none'
						});
						return;
					}
					// 数据处理
					const result = res.result;

					// 格式化日期
					['faultdate', 'maintdate', 'lrrq'].forEach(field => {
						if (result[field]) {
							result[field] = result[field].slice(0, 10);
						}
					});

					// 使用 $nextTick 确保 Vue 能正确响应数据变化
					this.$nextTick(() => {
						this.faultForm = result;
						// 确保设备编号存在后再获取相关数据
						if (this.faultForm.sbbh) {
							// this.getGzBwDataList();
						}
					});

				} catch (err) {
					this.faultForm = {};
					uni.showToast({
						title: '获取数据失败',
						icon: 'none'
					});
				}
			},

			//获取维修记录数据
			async getRepairData(id) {
				try {
					const res = await this.$commonUnits.postRequest(
						"deviceFaultRecord.deviceFaultRepair.getFaultRepairDetail.mobile", {
							id: id,
						}
					);
					// 数据处理
					const result = res.result;
					if (!res.result) {
						this.repairForm = {};
						uni.showToast({
							title: '暂无数据',
							icon: 'none'
						});
						return;
					}
					// 格式化日期
					['rq'].forEach(field => {
						if (result[field]) {
							result[field] = result[field].slice(0, 10);
						}
					});
					//转化 whetherstop 是否改为组件的true false
					result.whetherstop = result.whetherstop == '是' ? true : false;
					// console.log(result)
					this.$nextTick(() => {
						this.repairForm = result;
					});
				} catch (err) {
					this.faultForm = {};
					uni.showToast({
						title: '获取数据失败',
						icon: 'none'
					});
				}
			},

			//故障单号 弹窗相关
			gzdhLower() {
				this.gzdhpagination.pageNum++;
				this.getGzdhDataList();
			},
			gzdhClick(e) {
				this.showgzdh = false;
				this.faultForm.ldbh = e.ldbh
				this.faultForm.tjts = e.tjts
				this.repairForm.gznr = e.gznr

				// 赋值faultForm
				Object.keys(e).forEach(key => {
					// 检查faultForm中是否有这个属性
					if (this.faultForm.hasOwnProperty(key)) {
						// 处理日期时间字段
						if (key === 'lrrq' || key === 'createtime') {
							if (e[key] !== null && e[key] !== undefined) {
								// 提取日期部分，格式化为"YYYY-MM-DD"
								const dateValue = e[key].split(' ')[0];
								this.faultForm[key] = dateValue;
							}
						}
						// 特殊处理时间字段
						else if (key === 'xfsj') {
							if (e[key] !== null && e[key] !== undefined) {
								// 提取时间部分，格式化为"HH:mm"
								const timeValue = e[key].split(' ')[1] || e[key];
								this.faultForm[key] = timeValue;
							}
						} else {
							if (e[key] !== null && e[key] !== undefined) {
								this.faultForm[key] = e[key];
							}
						}
					}
				});

				//将故障日期和时间合并显示   修复日期 修复时间合并显示
				if (e.faultdate && e.faulttime) {
					this.faultForm.faultdate = e.faultdate.split(' ')[0]; // 只取日期部分
					this.faultForm.gzsj = e.faulttime; // 故障时间
				}
				if (e.maintdate && e.xfsj) {
					this.faultForm.maintdate = e.maintdate.split(' ')[0]; // 只取日期部分
					this.faultForm.xfsj = e.xfsj; // 故障时间
				}

				//操作人员为当前登录人
				this.faultForm.czry = this.$commonUnits.getUserId();

			},
			gzdhSearch(e) {
				this.gzdhsearchData.ldbh = e
				this.getGzdhDataList();
			},

			// 故障部位 弹窗相关
			gzbwLower(e) {},
			gzbwClick(e) {
				this.showgzbw = false;
				this.faultForm.faultpart = e.equipmentstructure
				this.faultpart = e.equipmentstructure
			},
			gzSearch(e) {
				this.gzbwsearchData.equipmentstructure = e
				this.getGzBwDataList();
			},

			// 维修人员 弹窗相关
			wxryChange(e) {
				const {
					value,
					columnIndex
				} = e;
				// 如果改变了班组列(第0列)
				if (columnIndex === 0) {
					const selectedTeam = value[0].value;
					this.currentWxryTeam = selectedTeam;
					// 更新人员列数据
					this.$set(this.wxryColumns, 1, this.wxryMap[selectedTeam] || []);
				}
			},
			wxryConfirm(e) {
				const [team, person] = e.value;
				if (team && person) {
					// 此处暂时不对故障单数据进行修改
					// this.faultForm.wxbz = team.label; // 班组名称
					// this.faultForm.wxry = person.label; // 人员名称
					this.repairForm.wxry = person.label;
				}
				this.showwzry = false;
			},


			// 操作人员 弹窗相关
			czryLower(e) {
				this.czrypagination.pageNum++;
				this.getEmployeeList();
			},
			czryClick(e) { //操作人员确认点击
				this.showczry = false;
				const name = e.empname;
				let current = this.faultForm.czry;
				// 1. 拆分为数组（过滤掉空项）
				let nameList = current ? current.split(',').filter(n => n) : [];
				// 2. 添加新名字
				if (!nameList.includes(name)) {
					nameList.push(name);
				}
				// 3. 拼接为字符串并赋值
				this.faultForm.czry = nameList.join(',');
			},
			czrySearch(e) {
				this.czrysearchData.employeeName = e
				this.getEmployeeList();
			},

			// 故障记录 弹窗相关
			gzjlLower(e) {},
			gzjlOpen() {
				// this.getGzjlDataList(); TODO
			},
			gzjlClick(e) { //故障记录确认点击
				this.showgzjl = false;
				const name = e.name;
				let current = this.faultForm.gznr;
				// 1. 拆分为数组（过滤掉空项）
				let nameList = current ? current.split(',').filter(n => n) : [];
				// 2. 添加新名字
				if (!nameList.includes(name)) {
					nameList.push(name);
				}
				// 3. 拼接为字符串并赋值
				this.faultForm.gznr = nameList.join(',');
				this.gznr = nameList.join(',');

			},
			gzjlConfirm(e) {
				//将故障信息的故障记录赋值到下方维修信息的故障现象
				this.repairForm.gznr = e.detail.value
			},
			gzjlSearch(e) {},

			jhtjChange(e) {

			},

			tjtsChange(e) { //故障停机台时 同步维修停机台时
				this.repairForm.tjts = e.value
			},

			//故障日期 弹窗相关
			openFaultDateTimePicker() {
				if (!this.isEditMode) return;
				// 如果有现有值，初始化选择器
				if (this.faultForm.faultdate && this.faultForm.gzsj) {
					const dateStr = this.faultForm.faultdate.slice(0, 10);
					const timeStr = this.faultForm.gzsj;
					// 拼接成完整的ISO格式字符串
					this.faultDateTime = new Date(`${dateStr} ${timeStr}`).getTime();
				} else {
					// 默认当前时间
					this.faultDateTime = Date.now();
				}
				this.showFaultDate = true;
			},

			faultDateConfirm(e) {
				const selectedDate = new Date(e.value);
				this.faultDateTime = e.value
				// 格式化日期部分 (YYYY-MM-DD)
				const year = selectedDate.getFullYear();
				const month = String(selectedDate.getMonth() + 1).padStart(2, '0');
				const day = String(selectedDate.getDate()).padStart(2, '0');
				const dateStr = `${year}-${month}-${day}`;
				// 格式化时间部分 (HH:mm)
				const hours = String(selectedDate.getHours()).padStart(2, '0');
				const minutes = String(selectedDate.getMinutes()).padStart(2, '0');
				const timeStr = `${hours}:${minutes}`;
				// 赋值到表单
				this.faultForm.faultdate = dateStr;
				this.faultForm.gzsj = timeStr;
				this.showFaultDate = false;
			},

			//维修日期时间 弹窗相关
			openMaintDateTimePicker() {
				if (!this.isEditMode) return;
				// 如果有现有值，初始化选择器
				if (this.faultForm.maintdate && this.faultForm.xfsj) {
					const dateStr = this.faultForm.maintdate.slice(0, 10);
					const timeStr = this.faultForm.xfsj;
					// 拼接成完整的ISO格式字符串
					this.MaintDateTime = new Date(`${dateStr} ${timeStr}`).getTime();
				} else {
					// 默认当前时间
					this.MaintDateTime = Date.now();
				}
				this.showMaintDate = true;
			},

			//故障记录 维修日期
			openRepairDatePicker() {
				if (this.repairForm.rq) {
					// repairDate格式为时间戳
					this.repairDate = new Date(`${this.repairForm.rq} `).getTime();
				} else {
					// 默认当前时间
					this.repairDate = Date.now();
				}
				this.showrq = true;
			},

			MaintDateConfirm(e) {
				const selectedDate = new Date(e.value);
				this.MaintDateTime = e.value
				// 格式化日期部分 (YYYY-MM-DD)
				const year = selectedDate.getFullYear();
				const month = String(selectedDate.getMonth() + 1).padStart(2, '0');
				const day = String(selectedDate.getDate()).padStart(2, '0');
				const dateStr = `${year}-${month}-${day}`;
				// 格式化时间部分 (HH:mm)
				const hours = String(selectedDate.getHours()).padStart(2, '0');
				const minutes = String(selectedDate.getMinutes()).padStart(2, '0');
				const timeStr = `${hours}:${minutes}`;

				this.faultForm.maintdate = dateStr; //维修日期
				this.faultForm.xfsj = timeStr; //修复时间
				this.showMaintDate = false;
				//同时将维修日期赋值到维修单的日期	
				this.repairForm.rq = dateStr
			},

			RepairRqConfirm(e) {
				this.repairForm.rq = this.formatTimestamp(e.value)
				this.showrq = false
			},

			xfsjConfirm(e) {
				this.xfsjValue = e.value
				this.faultForm.xfsj = e.value
				this.showxfsj = false;
			},

			async submitRepairCheck() {
				this.$refs.faultFormRef.validate().then(res => {
					this.$refs.repairFormRef.validate().then(res => {
						// 所有校验通过，显示确认弹窗
						this.isModalVisible = true;
					}).catch(errors => {
						uni.$u.toast('维修单校验失败');
						return;
					})
				}).catch(errors => {
					uni.$u.toast('故障单校验失败');
					return;
				})
			},

			async onSubmit() {
				try {
					const faultRecord = deepClone(this.faultForm);
					delete faultRecord.sbbh;
					delete faultRecord.sbmc;
					faultRecord.jhtj = faultRecord.jhtj ? 1 : 0;

					if (this.mode === 'add') {
						//新增故障单
						if (isBankObj(faultRecord.ldbh)) {
							// 获取故障单据号
							const serialRes = await this.$commonUnits.postRequest(
								"deviceFaultRecord.deviceFaultRecord.getFaultSerialNumber.mobile"
							);
							if (!serialRes.result[0]?.latestSerialNumber) {
								throw new Error('获取故障单号失败')
							}
							faultRecord.ldbh = serialRes.result[0].latestSerialNumber;
							faultRecord.id = this.generateDigitUUID();
							faultRecord.year = new Date().getFullYear();
							const addRes = await this.$commonUnits.postRequest(
								"deviceFaultRecord.deviceFaultRecord.AddFaultRecord.mobile", JSON
								.stringify({
									faultRecord: faultRecord
								})
							);
							if (!addRes) {
								uni.showToast({
									title: '新增故障单数据失败，请重试！',
									icon: 'success',
									duration: 1500, // 提示显示1秒
								});
							}
						} else {

							//修改故障单
							faultRecord.updateuserid = this.$commonUnits.getUserId();
							faultRecord.createtime = this.$commonUnits.FormatTimeOne(new Date(), true, true);


							const updateRes = await this.$commonUnits.postRequest(
								"deviceFaultRecord.deviceFaultRecord.UpdateFaultRecord.mobile", JSON.stringify({
									faultRecord: faultRecord
								})
							);
							if (!updateRes) {
								// 显示提示后延迟返回
								uni.showToast({
									title: '新增故障单数据失败，请重试！',
									icon: 'none',
									duration: 1500, // 提示显示1秒
								});
							}

						}

						//此处必为 新增维修单
						// 获取维修单据号
						const serialRes = await this.$commonUnits.postRequest(
							"deviceFaultRecord.deviceFaultRepair.getWXDSerialNumber.mobile"
						);
						if (!serialRes) {
							throw new Error('获取维修单号失败')
						}
						const faultRepair = deepClone(this.repairForm);
						faultRepair.sbid = faultRecord.sbid
						faultRepair.gzdh = faultRecord.ldbh
						faultRepair.year = new Date().getFullYear();
						faultRepair.ldbh = serialRes.result[0].latestSerialNumber;
						faultRepair.id = this.generateDigitUUID();
						const addRes = await this.$commonUnits.postRequest(
							"deviceFaultRecord.deviceFaultRepair.AddFaultRepair.mobile", JSON
							.stringify({
								faultRepair: faultRepair
							})
						);
						if (!addRes) {
							uni.showToast({
								title: '新增维修单失败，请重试!',
								icon: 'fail',
								duration: 1000, // 提示显示1秒
							});
						}

					} else {
						//修改故障单和维修单

						//修改故障单
						faultRecord.updateuserid = this.$commonUnits.getUserId();
						faultRecord.updatetime = this.$commonUnits.FormatTimeOne(new Date(), true, true);

						const updatefaultRecordRes = await this.$commonUnits.postRequest(
							"deviceFaultRecord.deviceFaultRecord.UpdateFaultRecord.mobile", JSON.stringify({
								faultRecord: faultRecord
							})
						);
						if (!updatefaultRecordRes) {
							// 显示提示后延迟返回
							uni.showToast({
								title: '新增故障单数据失败，请重试！',
								icon: 'success',
								duration: 1500, // 提示显示1秒
							});
						}

						//修改维修单
						const faultRepair = deepClone(this.repairForm);
						delete faultRepair.sbbh;
						delete faultRepair.sbmc;

						faultRepair.updateuserid = this.$commonUnits.getUserId();
						faultRepair.updatetime = this.$commonUnits.FormatTimeOne(new Date(), true, true);
						faultRepair.whetherstop = faultRepair.whetherstop ? '是' : '否';

						const updatefaultRepairRes = await this.$commonUnits.postRequest(
							"deviceFaultRecord.deviceFaultRepair.UpdateFaultRepair.mobile", JSON
							.stringify({
								faultRepair: faultRepair
							})
						);
						if (!updatefaultRepairRes) {
							uni.showToast({
								title: '新增维修单失败，请重试!',
								icon: 'fail',
								duration: 1000, // 提示显示1秒
							});
						}
					}


					this.isModalVisible = false; // 关闭弹窗
					uni.showToast({
						title: '操作成功，即将退出',
						icon: 'none',
						duration: 1000, // 提示显示1秒
					});

				} catch (err) {
					this.isEditMode = true;
					uni.showToast({
						title: '操作失败: ',
						icon: 'none'
					});
				}
			},


			onConfirm() { //设备员确认
				if (this.$userPerssion.sbyPermission()) {
					const faultRepair = deepClone(this.repairForm);
					delete faultRepair.sbbh;
					delete faultRepair.sbmc;
					faultRepair.sbyqr = this.$commonUnits.getUserId();
					faultRepair.sbyqrtime = new Date().toISOString().split('T')[0];
					this.$commonUnits.postRequest(
						'deviceFaultRecord.deviceFaultRepair.UpdateFaultRepair.mobile', JSON.stringify({
							faultRepair: faultRepair
						})).then(res => {
						if (res.result) {
							uni.showToast({
								title: '设备员确认成功，即将返回',
								icon: 'success',
								duration: 1000, // 提示显示1秒
								complete: () => {
									setTimeout(() => {
										uni.navigateBack();
									}, 500); // 提示消失后再等0.5秒
								}
							});
						} else {
							uni.showToast({
								title: '设备员确认失败，请重试！',
								icon: 'fail'
							});
						}
					});
				} else {
					uni.showToast({
						title: '您没有设备员的权限，请联系管理员配置！',
						icon: 'none'
					});
				}
				// 显示提示后延迟返回

			},

			cancelConfirm() { //撤销确认
				// debugger
				var userInfo = this.$commonUnits.getUserInfo();
				if (userInfo.userName != this.repairForm.sbyqr) {
					uni.showToast({
						title: '非本人确认的数据不可以进行撤销！',
						icon: 'none'
					});
				} else {
					if (this.$userPerssion.sbyPermission()) {
						this.$commonUnits.postRequest(
							'deviceFaultRecord.deviceFaultRepair.cancel.mobile', {
								id: this.repairForm.id,
								mode: "1",
							}
						).then(res => {
							if (res.result) {
								uni.showToast({
									title: '取消确认成功，即将返回',
									icon: 'success',
									duration: 1000, // 提示显示1秒
									complete: () => {
										setTimeout(() => {
											uni.navigateBack();
										}, 500); // 提示消失后再等0.5秒
									}
								});
							} else {
								uni.showToast({
									title: '撤销确认失败，请重试！',
									icon: 'fail'
								});
							}
						});
					} else {
						uni.showToast({
							title: '您没有设备员的权限，请联系管理员配置！',
							icon: 'none'
						});
					}
				}

			},

			onExamine() { //设备员审核
				if (this.$userPerssion.sbyPermission()) {
					// debugger
					const faultRepair = deepClone(this.repairForm);
					delete faultRepair.sbbh;
					delete faultRepair.sbmc;
					faultRepair.sbysh = this.$commonUnits.getUserId();
					faultRepair.sbyshtime = new Date().toISOString().split('T')[0];
					this.$commonUnits.postRequest(
						'deviceFaultRecord.deviceFaultRepair.UpdateFaultRepair.mobile', JSON.stringify({
							faultRepair: faultRepair
						})).then(res => {
						if (res.result) {
							uni.showToast({
								title: '设备科审核成功，即将返回',
								icon: 'success',
								duration: 1000, // 提示显示1秒
								complete: () => {
									setTimeout(() => {
										uni.navigateBack();
									}, 500); // 提示消失后再等0.5秒
								}
							});
						} else {
							uni.showToast({
								title: '设备科审核失败，请重试！',
								icon: 'fail'
							});
						}
					});

				} else {
					uni.showToast({
						title: '您没有设备科的权限，请联系管理员配置！',
						icon: 'none'
					});
				}
			},

			cancelExamine() { //撤销审核
				var userInfo = this.$commonUnits.getUserInfo();
				if (userInfo.userName != this.repairForm.sbysh) {
					uni.showToast({
						title: '非本人审核的数据不可以进行撤销！',
						icon: 'none'
					});
				} else {
					if (this.$userPerssion.sbyPermission()) {
						this.$commonUnits.postRequest(
							'deviceFaultRecord.deviceFaultRepair.cancel.mobile', {
								id: this.repairForm.id,
								mode: "2",
							}
						).then(res => {
							if (res.result) {
								uni.showToast({
									title: '取消审核成功，即将返回',
									icon: 'success',
									duration: 1000, // 提示显示1秒
									complete: () => {
										setTimeout(() => {
											uni.navigateBack();
										}, 500); // 提示消失后再等0.5秒
									}
								});
							} else {
								uni.showToast({
									title: '设备科撤销审核失败，请重试！',
									icon: 'fail'
								});
							}
						});

					} else {
						uni.showToast({
							title: '您没有设备科的权限，请联系管理员配置！',
							icon: 'none'
						});
					}
				}
			},

			scanCode(e) {
				uni.scanCode({
					success: (res) => {
						// 进行查询设备信息,并且填充
						this.getGzBwDataList();
					}
				});
			},
			formatter(type, value) {
				if (type === 'year') {
					return `${value}年`;
				}
				if (type === 'month') {
					return `${value}月`;
				}
				if (type === 'day') {
					return `${value}日`;
				}
				if (type === 'hour') {
					return `${value}时`;
				}
				if (type === 'minute') {
					return `${value}分`;
				}
				return value;
			},
			formatTimestamp(timestamp) {
				const date = new Date(timestamp);
				const year = date.getFullYear();
				const month = String(date.getMonth() + 1).padStart(2, '0');
				const day = String(date.getDate()).padStart(2, '0');
				const hours = String(date.getHours()).padStart(2, '0');
				const minutes = String(date.getMinutes()).padStart(2, '0');
				const seconds = String(date.getSeconds()).padStart(2, '0');
				return `${year}-${month}-${day}`;
			},
			generateDigitUUID() {
				let result = '';
				for (let i = 0; i < 32; i++) {
					result += Math.floor(Math.random() * 10); // 0-9随机数
				}
				return result;
			},
		}
	};
</script>

<style>
	.container {
		padding-bottom: 120rpx;
		/* 根据按钮高度调整 */
	}

	.form-section {
		padding: 20rpx;
	}

	.form-group {
		background: #ffffff;
		border-radius: 12rpx;
		padding: 24rpx;
		margin-bottom: 20rpx;
	}

	.form-title {
		font-size: 28rpx;
		font-weight: 500;
		color: #333;
		margin-bottom: 20rpx;
		border-left: 4rpx solid #1890ff;
		padding-left: 12rpx;
	}

	.form-item {
		display: flex;
		align-items: center;
		padding: 16rpx 0;
		border-bottom: 1rpx solid #f0f0f0;
	}



	.textarea-field {
		width: 100%;
		padding: 10rpx;
		border: 1rpx solid #ddd;
		border-radius: 6rpx;
		margin-top: 2px;
		height: 100rpx;
		width: auto;
	}

	/**
	 *日期选择
	 */
	.datetime-btn {
		width: 100%;
		text-align: left;
		padding: 0;
		margin: 0;
		border: none !important;
		background-color: transparent !important;
		color: inherit !important;
		font-size: inherit !important;
		height: auto;
		line-height: normal;
	}

	.datetime-btn[disabled] {
		opacity: 1;
		color: #999 !important;
	}

	.datetime-btn::after {
		border: none !important;
	}

	/* 编辑按钮 */

	.btn-container {
		text-align: center;
	}

	.edit-btn {
		padding: 0 16px;
		height: 32px;
		line-height: 32px;
		font-size: 14px;
		background-color: #f0f0f0;
		color: #333;
		border: 1px solid #ddd;
		border-radius: 4px;
	}

	.submit-btn {
		width: 100%;
		background: #003b90;
		color: white;
		padding: 12rpx;
		border-radius: 6rpx;
	}

	.confirm-btn {
		flex: 1;
		height: 80rpx;
		width: 80%;
		line-height: 80rpx;
		text-align: center;
		border-radius: 40rpx;
		font-size: 28rpx;
		margin: 0 10rpx;
	}

	.section {
		padding: 16px;
		background-color: #f9f9f9;
		border: 1px solid #ddd;
		border-radius: 8px;
	}

	.section-title {
		font-size: 28rpx;
		font-weight: 500;
		color: #333;
		margin-bottom: 20rpx;
		border-left: 4rpx solid #1890ff;
		padding-left: 12rpx;
	}



	/*展开更多*/
	.toggle-button {
		text-align: center;
		cursor: pointer;
		margin-bottom: 12px;
	}

	.toggle-button text {
		font-size: 14px;
	}

	/* 操作按钮容器 */
	.action-buttons {
		/* 		display: flex;
		flex-wrap: wrap;
		justify-content: center;
		gap: 15rpx;
		margin: 20rpx 0;
		padding: 0 20rpx; */
		position: fixed;
		left: 0;
		right: 0;
		bottom: 0;
		background: rgba(255, 255, 255, 0);
		padding: 20rpx 30rpx;
		z-index: 999;
	}

	/* 基础按钮样式 */
	.action-btn {
		flex: 1;
		min-width: 200rpx;
		height: 80rpx;
		border-radius: 40rpx;
		font-size: 28rpx;
		font-weight: 500;
		display: flex;
		align-items: center;
		justify-content: center;
		box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
		transition: all 0.3s ease;
	}

	/* 按钮悬停效果 */
	.action-btn:hover {
		transform: translateY(-2rpx);
		box-shadow: 0 6rpx 16rpx rgba(0, 0, 0, 0.15);
	}

	/* 按钮按下效果 */
	.action-btn:active {
		transform: translateY(1rpx);
		box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
	}

	/* 图标和文字间距 */
	.action-btn u-icon {
		margin-right: 8rpx;
	}

	/* 确认按钮 */
	.confirm-btn {
		background: linear-gradient(135deg, #2979ff, #4a90e2);
		border: none;
	}

	/* 撤销确认按钮 */
	.cancel-confirm-btn {
		background: linear-gradient(135deg, #ff9900, #ffad33);
		border: none;
	}

	/* 审核按钮 */
	.examine-btn {
		background: linear-gradient(135deg, #19be6b, #36cf89);
		border: none;
	}

	/* 撤销审核按钮 */
	.cancel-examine-btn {
		background: linear-gradient(135deg, #fa3534, #ff5c5c);
		border: none;
	}

	/* 响应式调整 */
	@media (max-width: 500px) {
		.action-btn {
			min-width: 45%;
			font-size: 26rpx;
		}
	}

	/* 标题区域 */
	.section-title {
		font-size: 28rpx;
		font-weight: 500;
		color: #333;
		margin-bottom: 20rpx;
		border-left: 4rpx solid #1890ff;
		padding-left: 12rpx;
	}

	.gznr-textarea {}

	.textarea-title {
		display: flex;
		justify-content: space-between;
		align-items: center;
		width: 100%;
		padding: 0 8rpx;
	}

	.title-icon {
		margin-left: auto;
		color: #2979ff;
		margin-right: 8rpx;
	}

	.textarea-container {
		display: flex;
	}

	/* 文本框样式 */
	.textarea-style {
		width: 100%;
		min-height: 100px;
		font-size: 14px;
		line-height: 1.6;
		padding: 12px;
		box-sizing: border-box;
	}


	::v-deep .u-form-item__body {
		display: flex !important;
		align-items: center !important;
		padding: 16rpx 0 !important;
		border-bottom: 1rpx solid #f0f0f0 !important;
	}

	/* 左侧图标label */
	::v-deep .u-form-item__body__left__content__label {
		min-width: 120rpx !important;
		color: #666 !important;
		font-size: 26rpx !important;
	}

	::v-deep .u-form-item__body__right__content {
		flex: 1 !important;
		color: #333 !important;
		font-size: 26rpx !important;
	}
</style>